package com.zhouyu.fileSync.FScommon.commonUtils;

import org.yaml.snakeyaml.Yaml;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Created by zhouyu@lightinthebox.com on 2019/8/7
 * yml reader
 * get config from yml file and create a config object
 **/
public class ConfigReader {
    public static <T> T readConfigs(String filePath, Class<T> clazz) throws FileNotFoundException {
        InputStream in = new FileInputStream(new File(filePath));
        Yaml yaml = new Yaml();
        Object config = yaml.loadAs(in, clazz);
        return (T) config;
    }
}
